package com.zukxu.items.common;

import com.zukxu.items.common.response.Res;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * <p>
 * 路由控制器
 * </p>
 *
 * @author zukxu
 * @date 2020/12/22 0022 15:51
 */
@Controller
public class RouterController {

	@GetMapping({"/"})
	public String index(Model model) {
		model.addAttribute("username", "zukxu");
		return "layout";
	}

	@GetMapping({"/test"})
	public String test(Model model) {
		model.addAttribute("object", Res.success());
		model.addAttribute("name", "zukxu");
		model.addAttribute("msg", "success");
		model.addAttribute("age", 21);
		model.addAttribute("birthday", LocalDate.now());
		model.addAttribute("num", 22.25);
		model.addAttribute("isNull", true);
		int[] ints = {22, 33, 44, 55};
		model.addAttribute("score", ints);
		ArrayList<Integer> list = new ArrayList<>();
		list.add(1);
		list.add(2);
		list.add(3);
		model.addAttribute("list", list);
		HashMap<String, String> map = new HashMap<>();
		map.put("name", "金属性");
		map.put("msg", "木属性");
		map.put("age", "岁");
		model.addAttribute("map", map);
		return "test";
	}

	@GetMapping("/minio")
	public String minio() {
		return "minio";
	}

	@GetMapping("/upload")
	public String upload() {
		return "upload";
	}

}
